package com.compass.doctor.ui.chat.attachment

import com.compass.doctor.R
import com.compass.framework.constant.EXAMINE_CODE
import com.compass.framework.utils.getStringFromResource
import com.netease.yunxin.kit.corekit.im.custom.CustomAttachment
import org.json.JSONObject

/**
 * Description： 检验检查
 * Date:2024/1/22 17:21
 */
class ExamineAttachment : CustomAttachment(EXAMINE_CODE) {
    private var diagnosisName: String? = null //诊断
    private var departmentName: String? = null//科室
    private var inspectionName: String? = null//项目
    private var price: Long? = 0//费用
    private var id: String? = null//检验检查id

    //重写数据解析方法，这里面数据以JSONObject格式进行传输，所以您可以制定自己的数据格式。
    //这个示例表示，自定义数据格式为{"customer_message_key":"我是一个自定义消息"}
    override fun packData(): JSONObject {
        var data = JSONObject()
        data.put("diagnosisName", diagnosisName)
        data.put("departmentName", departmentName)
        data.put("inspectionName", inspectionName)
        data.put("price", price)
        data.put("id", id)
        return data
    }


    override fun parseData(jsonObject: JSONObject?) {
        // 从接收到的消息内容中解析您的数据
        jsonObject?.let {
            this.diagnosisName = jsonObject.getString("diagnosisName")
            this.departmentName = jsonObject.getString("departmentName")
            this.inspectionName = jsonObject.getString("inspectionName")
            this.price = jsonObject.getLong("price")
            this.id = jsonObject.getString("id")
        }

    }


    /**
     * 设置检验检测数据
     */
    fun setExamineData(diagnosisName: String?, departmentName: String?, inspectionName: String?, id: String,price:Long) {
        this.diagnosisName = diagnosisName;
        this.departmentName = departmentName;
        this.inspectionName = inspectionName;
        this.price = price;
        this.id = id;

    }


    override fun getContent(): String {
        return getStringFromResource(R.string.attachment_examine_msg)
    }



    fun getDiagnosisName(): String? {
        return diagnosisName;
    }

    fun getDepartmentName(): String? {
        return departmentName;
    }

    fun getInspectionName(): String? {
        return inspectionName;
    }
    fun getPrice(): Long? {
        return price;
    }

    fun getId(): String? {
        return id;
    }

}